{template '../../header'}
{template '../../left'}

<div class="card">
    <div class="card-header">
        修改文章
    </div>
    <div class="card-body">
        <form class="form-row" method="post">
            <div class="form-group col-4">
                <label>文章标题</label>
                <input class="form-control form-control-sm" type="text" maxlength="50" name="title" value="{$detail['title']}">
            </div>
            <div class="form-group col-2">
                <label>栏目</label>
                <select name="column_id" class="form-control form-control-sm">
                    {loop $columns $column}
                    <option value="{$column['id']}" {if $detail['column_id'] == $column['id']}selected{/if}>{$column['title']}</option>
                    {/loop}
                </select>
            </div>
            <div class="form-group col-1">
                <label>类型</label>
                <select name="type" class="form-control form-control-sm">
                    {loop $types $type $title}
                    <option value="{$type}" {if $detail['type'] == $type}selected{/if}>{$title}</option>
                    {/loop}
                </select>
            </div> 
            <div class="form-group col-2">
                <label>
                    公告板推荐
                    <span class="badge badge-pill badge-info" 
                          data-toggle="tooltip" 
                          title="设置后推荐到公告板，并按顺序展示">?</span>
                </label>
                <input type="number" name="top" class="form-control form-control-sm" value="{$detail['top']}" />
            </div>
            <div class="form-group col-2">
                <label>
                    栏目推荐
                    <span class="badge badge-pill badge-info" 
                          data-toggle="tooltip" 
                          title="设置后推荐到首页分栏目列表，以及列表页和详情页右侧推荐栏，并按顺序展示">?</span>
                </label>
                <input type="number" name="hot" class="form-control form-control-sm" value="{$detail['hot']}" />
            </div>
            <div class="form-group col-1">
                <label>
                    排序
                    <span class="badge badge-pill badge-info" 
                          data-toggle="tooltip" 
                          title="文章在所在栏目的文章列表页中的排序">?</span>
                </label>
                <input type="text" name="sort" class="form-control form-control-sm" value="{$detail['sort']}">
            </div>
            <div class="form-group col-4">
                <label>关键字</label>
                <input class="form-control form-control-sm" type="text" maxlength="100" name="keywords" value="{$detail['keywords']}">
            </div>
            <div class="form-group col-4">
                <label>跳转地址</label>
                <input type="text" name="redirect" class="form-control form-control-sm" value="{$detail['redirect']}">
            </div>
            <div class="form-group col-1">
                <label>跳转方式</label>
                <label class="form-control form-control-sm">
                    <input type="checkbox" name="jump" value="1" {if $detail['jump']}checked="checket"{/if}>
                    自动
                </label>
            </div>
            <div class="form-group col-2">
                <label>发布时间</label>
                <input type="text" name="publish_time" class="form-control form-control-sm datetimepicker" value="{$detail['publish_time']}">
            </div>
            <div class="form-group col-1">
                <label>是否显示</label>
                <select name="state" class="form-control form-control-sm">
                    {loop $states $key $value}
                    <option value="{$key}" {if $detail['state']==$key}selected{/if}>{$value}</option>
                    {/loop}
                </select>
            </div>
            <div class="form-group col-8">
                <label>文章简介</label>
                <textarea class="form-control form-control-sm" rows="4" maxlength="500" name="description">{$detail['description']}</textarea>
            </div>
            <div class="form-group col-4">
                <label>缩略图</label>
                <div class="form-control-static">
                    <label id="preview" class="preview thumb">
                        +<input type="file" id="file" accept="image/*" />
                        <input type="hidden" id="thumb" name="thumb" value="{$detail['thumb']}" />
                    </label>
                    <script type="text/javascript">
                        var loading;
                        $("#file").uploadImagePreview({
                            destID: "preview",
                            imgUrl: "{$detail['thumb']}",
                            server: "/admin/upload/base64?dir=cms/article",
                            change: function (image) {
                                $("#thumb").val(image);
                            },
                            startUpload: function () {
                                loading = $.loading({title: '正在上传...'});
                            },
                            finishUpload: function () {
                                loading.unloading();
                            },
                        });
                    </script>
                </div>
            </div>
            <div class="form-group col-12">
                <label>标签</label>
                <div class="form-control">
                    {loop $tags $tag}
                    <label><input type="checkbox" name="tag_ids[]" value="{$tag['id']}" {if $tag['checked']}checked="checked"{/if} /> {$tag['title']}</label>&nbsp;&nbsp;&nbsp;
                    {/loop}
                </div>
            </div>
            <div class="form-group col-12">
                <label>文章内容</label>
                {php $editor->create()}
            </div>
            <div class="form-group col-12">
                <button type="submit" class="btn btn-success btn-sm"><i class="fa fa-save"></i> 保存</button>
            </div>
        </form>
    </div>
</div>

{template '../../footer'}   